﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using DBUtility;
using TTSIDAL;
using TTSModel;
namespace TTSDAL
{
    public class AxisValue : BaseRepository_DT<AxisValueInfo>, IAxisValue
    {
        #region 静态变量定义

        private const string PARMStartSN = "@StartSN";
        private const string PARMEndSN = "@EndSN";
        private const string PARM_ParamaterName = "@ParamaterName";
        private const string PARM_TestType = "@TestType";
        #endregion

        #region 数据检索部分
        public IList<AxisValueInfo> LoadEntities()
        {
            return null;
        }

        public AxisValueInfo LoadEntity<T1>(T1 id)
        {          
            return null;
        }

        public IList<AxisValueInfo> AxisValue_GetbySNRange(string spName, string startSN, string endSN, string parameterName, string testType)
        {
            SqlParameter[] parms = GetParameters();
            parms[0].Value = startSN;
            parms[1].Value = endSN;
            parms[2].Value = parameterName;
            parms[3].Value = testType;
            return ExcuteSqlToGetEntities(spName, parms);
        }
        #endregion

        #region 重写基类方法
        public override AxisValueInfo GetEntityRecord(SqlDataReader rdr)
        {
            AxisValueInfo entity = new AxisValueInfo()
            {
                XAxis = (double)rdr.GetDecimal(0), //== DBNull.Value ? "0.0" : Convert.ToString(rdr.GetDecimal(0)),
                YAxis = rdr.GetInt32(1) //== DBNull.Value ? "0" : Convert.ToString(rdr.GetInt32(1))
            };
            return entity;
        } 

        public override AxisValueInfo GetEntityRecord()
        {
            AxisValueInfo entity = new AxisValueInfo();
            return entity;
        }

        public override SqlParameter GetParameter()
        {
            SqlParameter parm = new SqlParameter(PARM_ParamaterName, SqlDbType.NVarChar, 150);
            return parm;
        }

        public override SqlParameter[] GetParameters()
        {
            SqlParameter[] parms = new SqlParameter[]
            {              
                new SqlParameter(PARMStartSN,SqlDbType.NVarChar,10),
                new SqlParameter(PARMEndSN,SqlDbType.NVarChar,10),
                new SqlParameter(PARM_ParamaterName,SqlDbType.NVarChar,150),
                new SqlParameter(PARM_TestType,SqlDbType.NVarChar,10),
            };
            return parms;
        }

        public override void SetParameters(AxisValueInfo Entity, params SqlParameter[] Parms)
        {
            Parms[0].Value = Entity.XAxis;
            Parms[1].Value = Entity.YAxis;
           
        }
        #endregion
    }
}
